package com.mt.demo.controller;

import com.mt.demo.domain.AjaxResult;
import com.mt.demo.domain.MtVoteOption;
import com.mt.demo.domain.TableDataInfo;
import com.mt.demo.service.IMtVoteOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投票选项Controller
 * 
 * @author gary
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/mt/mtOption")
public class MtVoteOptionController extends BaseController
{
    @Autowired
    private IMtVoteOptionService mtVoteOptionService;

    /**
     * 查询投票选项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtVoteOption mtVoteOption)
    {
        startPage();
        List<MtVoteOption> list = mtVoteOptionService.selectMtVoteOptionList(mtVoteOption);
        return getDataTable(list);
    }

    /**
     * 导出投票选项列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MtVoteOption mtVoteOption)
    {
        List<MtVoteOption> list = mtVoteOptionService.selectMtVoteOptionList(mtVoteOption);
//        ExcelUtil<MtVoteOption> util = new ExcelUtil<MtVoteOption>(MtVoteOption.class);
//        util.exportExcel(response, list, "投票选项数据");
    }

    /**
     * 获取投票选项详细信息
     */
    @GetMapping(value = "/{optionId}")
    public AjaxResult getInfo(@PathVariable("optionId") Long optionId)
    {
        return success(mtVoteOptionService.selectMtVoteOptionByOptionId(optionId));
    }

    /**
     * 新增投票选项
     */
    @PostMapping
    public AjaxResult add(@RequestBody MtVoteOption mtVoteOption)
    {
        return toAjax(mtVoteOptionService.insertMtVoteOption(mtVoteOption));
    }

    /**
     * 修改投票选项
     */
    @PutMapping
    public AjaxResult edit(@RequestBody MtVoteOption mtVoteOption)
    {
        return toAjax(mtVoteOptionService.updateMtVoteOption(mtVoteOption));
    }

    /**
     * 删除投票选项
     */
	@DeleteMapping("/{optionIds}")
    public AjaxResult remove(@PathVariable Long[] optionIds)
    {
        return toAjax(mtVoteOptionService.deleteMtVoteOptionByOptionIds(optionIds));
    }
}
